package com.hc.javabasestudyproject.juc.threefeature;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: huangcheng
 * @CreateTime: 2024-06-06  15:06
 * @Description: 可见性测试
 * @Version: 1.0
 */
public class Visibility {
    private volatile long count = 0;
    public void execute(){
        ExecutorService executorService = Executors.newFixedThreadPool(100);
        for (int i = 0; i < 100000; i++) {
            executorService.execute(new Thread(()->{
                count++;
            }));
        }
    }
    public static void main(String[] args) {
        Visibility visibility = new Visibility();
        visibility.execute();
        System.out.println(visibility.count);
    }
}
